﻿using System;
using System.Configuration;

namespace DotNetServiceAssembly.LoadAppSettings
{
    class ConnectionStringLoader
    {
        public static string TryToLoad(string settingName)
        {
            string connString;
            if (ConfigurationManager.ConnectionStrings[settingName] != null)
                connString = ConfigurationManager.ConnectionStrings[settingName].ConnectionString;
            else
                throw new Exception(String.Format("Connectionstring with name {0} could not be loaded.", settingName));
            return connString;
        }
    }
}